import axios from '../utils/request'
import path from './path'

const api={
    newRegist(data:any){
        return axios.post(path.regist,{
            username: data.username,
            email: data.email,
            userpwd: data.userpwd
        })
    },
    newLogin(data:any){
        console.log('提交数据:', data)//提交数据
        return axios.post(path.login,{
            username: data.username,
            nametag: data.nametag,
            userpwd: data.userpwd
        })
    },
    newProblem(data: any) {
        console.log('提交题目', data);
        const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJxaWQiOiIxMTExMTExMTExIiwicW5hbWUiOiJSQ2VsbHMiLCJleHAiOjE3NDI2NzQ4MTMsIm5iZiI6MTc0MjU4ODQxMywiaWF0IjoxNzQyNTg4NDEzfQ.gw2-ULFQXjT0vrvwh1Fh29N7l5LJllq6kpU7n-veURo'; // 替换为你的固定 token
        return axios.post(path.createProblem, {
            title: data.title,
            tag: data.tag,
            rank: data.rank,
            dc: data.dc,
            input: {
                cnt: data.input.cnt,
                data: data.input.data,
            },
            output: {
                cnt: data.output.cnt,
                data: data.output.data,
            },
            exDc: data.exDc,
            limit: {
                timeLimit: data.limit.timeLimit,
                memoryLimit: data.limit.memoryLimit,
            },
            contest: data.contest,
        }, {
            headers: {
                'Authorization': `Bearer ${token}`, // 添加 token 到 headers
            },
        });
    }
}
export default api